Apple just released Beta 2 of the WatchKit SDK. There are a few things that got updated, but by far the most significant update is the addition of a pair of methods permitting interactivity between the host and extension apps.
Like I mentioned in the previous link post one of the trickiest parts of building a WatchKit app is dealing with the concurrency between the host and extension. Jared Sinclair has a great pair of posts detailing some of these issues.
At their core, all these issues stem from needing a reliable method for coordinating the actions of the extension and the host app.
This is basically what Apple just introduced. I’ll let Apple describe how this now works by quoting from the updated section of the Programming Guide.
Communicating Directly with Your Containing iOS App
Apps that work closely with their parent iOS app can use the openParentApplication:reply: method to send requests to the parent app. App extensions run only while the user is interacting with the app on Apple Watch and do not support background execution modes. Parent apps have fewer restrictions and can be configured to run in the background or to gather information on behalf of the WatchKit extension.
When you call the openParentApplication:reply: method, iOS launches or wakes up the parent app in the background and calls the application:handleWatchKitExtensionRequest:reply: method of its app delegate. The app delegate can use the provided dictionary to perform any requests and return a reply to the WatchKit app.
I’m still doing some testing about what the full capabilities of this are going to be, but this is amazingly good news. There are a bunch of low level data management tasks that just got a whole lot simpler. There are now a whole bunch of application capabilities that just became possible.
We’ll likely never know if this functionality was planned all along or is a reaction to our Radars. I don’t really care. Either way I’m really excited about the change and encouraged to keep on filing my enhancement requests.